# 1．Get请求的params与post请求的data与json案例
# url = 'http://httpbin.org/get'
# response = requests.get(url, params={
#     'name':'fcb',
#     'age': '21',
#     'like': 'eat'
# })
# print(response.text)

# url = 'http://httpbin.org/post'
# response = requests.post(url,
# data={
#     'name':'fcb',
#     'age': '21',
#     'like': 'eat'
# })
# print(response.json())

# response = requests.post(url,
# json={
#     'name':'fcb',
#     'age': '21',
#     'like': 'eat'
# }
# )
# print(response.json())


# 2．响应的content、text、json()案例
# url = 'http://httpbin.org/post'
# response = requests.post(url,
# json={
#     'name':'fcb',
#     'age': '21',
#     'like': 'eat'
# }
# )
# print(response.content)
# print(response.text)
# print(response.json())


# 3．allow_redirects、headers、cookies、auth参数使用案例
# url = 'http://127.0.0.1:8000/admin/'
# response = requests.get(url, allow_redirects=False)
# print(response.status_code)
# print(response.headers.get('location'))
# location = response.headers.get('location')
# location = f'http://127.0.0.1:8000{location}'
# response = requests.get(location)
# print(response.status_code)

# headers = {
    # 'cookie':'sessionid=js4no6j5vl1py9ytmgxb3giuwuoat70u'
    # }
# cookies = {'sessionid':'js4no6j5vl1py9ytmgxb3giuwuoat70u'}
# response = requests.get(url, headers=headers, cookies=cookies)
# response = requests.get(url,auth=HTTPBasicAuth('admin','password'))
# print(response.status_code)
# print(response.text)